package oop.ex3.filemanager.actions;

import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;

import oop.ex3.filemanager.FMContext;

public class PrintServers extends FmAction {

	private String SEPERATION_CHAR = " ";

	/**
	 * construct a new PrintSevers action
	 * @param context
	 */
	public PrintServers(FMContext context) {
		super(context);
	}

	/**
	 * prints all serversd FM knows
	 */
	public void run(String[] params) {
		LinkedHashSet<InetSocketAddress> servers = _context.getServersSet();
		for (InetSocketAddress server : servers){
			//TODO check if you need hostName or address
			//TODO check if you need Port.toString
			System.out.println(server.getAddress().toString()+
					SEPERATION_CHAR+server.getPort());
		}
	}

}
